package io.hepu.robotize;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class ID {
    static String[] arrays = new String[] {
            "tb_address",
            "tb_brand",
            "tb_bulletin",
            "tb_bulletin_category",
            "tb_card",
            "tb_card_consume",
            "tb_card_user",
            "tb_comment_image",
            "tb_company",
            "tb_coupon",
            "tb_coupon_order",
            "tb_coupon_scope",
            "tb_coupon_user",
            "tb_customer",
            "tb_customer_service",
            "tb_department",
            "tb_district",
            "tb_ensure",
            "tb_erp_product",
            "tb_express",
            "tb_goods",
            "tb_goods_carousel",
            "tb_goods_category",
            "tb_goods_ensure",
            "tb_goods_favourite",
            "tb_goods_order",
            "tb_group",
            "tb_group_role",
            "tb_group_user",
            "tb_integral",
            "tb_logistics",
            "tb_lottery_activity",
            "tb_lottery_award",
            "tb_lottery_category",
            "tb_lottery_draw",
            "tb_lottery_vehicle",
            "tb_oauth",
            "tb_order",
            "tb_order_comment",
            "tb_order_delivery",
            "tb_order_economize",
            "tb_pay_refund",
            "tb_pay_transfer",
            "tb_payment",
            "tb_permission",
            "tb_postage",
            "tb_postage_forbid",
            "tb_postage_free",
            "tb_postage_region",
            "tb_push_log",
            "tb_recharge",
            "tb_recharge_order",
            "tb_role",
            "tb_role_permission",
            "tb_sku",
            "tb_sku_erp",
            "tb_sku_image",
            "tb_spec",
            "tb_spec_group",
            "tb_spec_item",
            "tb_swiper",
            "tb_terms",
            "tb_unit",
            "tb_user",
            "tb_user_role",
            "tb_user_vehicle",
            "tb_vehicle",
            "tb_vip",
            "tb_vip_card",
            "tb_vip_order",
            "ts_option",
            "ts_syslog"
    };

    public static void main(String[] args) {
        Set<Integer> set = new HashSet<>();
        System.out.println(arrays.length);
        Arrays.stream(arrays).forEach(ele -> {
            int shortNumericUUID = getShortCustomHash(ele);
            set.add(shortNumericUUID);
            System.out.println(shortNumericUUID);
        });
        System.out.println(set.size());
    }

    public static int getShortCustomHash(String input) {
        int hash = 0;
        for (int i = 0; i < input.length(); i++) {
            hash = 31 * hash + input.charAt(i);
        }
        // 将哈希值限制在一个较小范围（例如 6 位数以内）
        return Math.abs(hash) % 1000000; // 6 位数
    }
}
